/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mwt.xml.xdbforms.xformlayer.transactions.impl;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXParseException;

/**
 * Progetto Master Web Technology
 * @author Gianfranco Murador, Cristian Castiglia, Matteo Ferri
 * @copyright (C) 2009, MCG08
 */
public class ValidatorErrorHandler implements ErrorHandler {

    private int nErrors,  nWarnings,  nFatals;

    public ValidatorErrorHandler() {
        reset();
    }

    public void reset() {
        nErrors = 0;
        nWarnings = 0;
        nFatals = 0;
    }

    public boolean hadProblems() {
        return (nErrors + nFatals > 0);
    }

    public void warning(SAXParseException e) throws org.xml.sax.SAXException {
        nWarnings++;
    }

    public void error(SAXParseException e) throws org.xml.sax.SAXException {
        nErrors++;
        e.printStackTrace();

    }

    public void fatalError(SAXParseException e) throws org.xml.sax.SAXException {
        nFatals++;
        e.printStackTrace();
    }
}
